VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "colRegKeys"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit


'local variable to hold collection
Private mCol As Collection
Private mKey As Long

Public Sub Add(ByVal NewKey As ApiRegKey)

    mCol.Add NewKey, NewKey.Name
    
End Sub

Public Property Get Item(vntIndexKey As Variant) As ApiRegKey
    'used when referencing an element in the collection
    'vntIndexKey contains either the Index or Key to the collection,
    'this is why it is declared as a Variant
    'Syntax: Set foo = x.Item(xyz) or Set foo = x.Item(5)
  Set Item = mCol(vntIndexKey)
End Property



Public Property Get Count() As Long
    'used when retrieving the number of elements in the
    'collection. Syntax: Debug.Print x.Count
    Count = mCol.Count
End Property



'\\ --[NewKey]---------------------------------------------------------
'\\ Creates and adds a new registry to this collection of subkeys.
'\\ -------------------------------------------------------------------
Public Function NewKey(ByVal Name As String) As ApiRegKey

Dim tmpKey As ApiRegKey

With tmpKey
    .Name = Name
    .ParentKey = Me.ParentKey
    .OpenKey
End With

Me.Add tmpKey

Set NewKey = tmpKey

End Function

Friend Property Get ParentKey() As Long

    ParentKey = mKey
    
End Property

Friend Property Let ParentKey(ByVal NewKey As Long)

    mKey = NewKey
    
End Property


Public Sub Remove(vntIndexKey As Variant)
    'used when removing an element from the collection
    'vntIndexKey contains either the Index or Key, which is why
    'it is declared as a Variant
    'Syntax: x.Remove(xyz)


    mCol.Remove vntIndexKey
End Sub


Public Property Get NewEnum() As IUnknown
    'this property allows you to enumerate
    'this collection with the For...Each syntax
    Set NewEnum = mCol.[_NewEnum]
End Property


Private Sub Class_Initialize()
    'creates the collection when this class is created
    Set mCol = New Collection
End Sub


Private Sub Class_Terminate()
    'destroys collection when this class is terminated
    Set mCol = Nothing
End Sub
